package com.smartscreen.baseinfomanage.controller;


import com.smartscreen.baseinfomanage.dto.CreateSubjectRequest;
import com.smartscreen.baseinfomanage.entity.Subject;
import com.smartscreen.baseinfomanage.service.SubjectService;
import com.smartscreen.common.response.ApiResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/base")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    @GetMapping("/subjects")
    public ApiResponse<List<Subject>> getAllSubjects() {
        List<Subject> subjects = subjectService.getAllSubjects();
        return ApiResponse.success(subjects);
    }

    @PostMapping("/subjects")
    public ApiResponse<Subject> createSubject(@RequestBody CreateSubjectRequest request) {
        Subject subject = subjectService.createSubject(request);
        return ApiResponse.created("创建成功", subject);
    }

    @PostMapping("/subjects/batch")
    public Map<String, Map<String, Object>> getSubjectsBatch(@RequestBody List<String> subjectIds) {
        return subjectService.getSubjectsBatchAsMap(subjectIds);
    }
}